require(['jquery','token','sweetalert'], function($,token,swal) {
	var content = new Vue({
		el: '#content',
		methods: {
			submit: function(){
				var name=$('#username').val();
				var password=$('#password').val();
				if(!name){
					swal("Oops...", "用户名不能为空", "error");
				}else if(!password){
					swal("Oops...", "密码不能为空", "error")
				}else {
					$.ajax({
						method: 'post',
						data: {
							name: name,
							password: password
						},
						success: function (data) {
							if (data.err) {
								swal("Oops...", data.err, "error")
							} else {
								swal({
										title: "成功",
										text: "注册成功，点击确定至登陆页进行登陆",
										type: "success"
									},
									function () {
										window.location.href = '/login';
									})
							}
						}
					})
				}
			}
		}
	})
});